<template>
	<view>
		<Header :title="title"></Header>
		<view class="toubu">
			<view class="middle-content" v-if="state==1">
				<image :src="avatar" @click="publics.tupian(avatar)"></image>
				<image class="aimg" src="/static/image/me/change.png" v-if="state==1" @tap="touxiang"></image>
			</view>
			<view class="middle-content" v-else>
				<image :src="shoplogo" @click="publics.tupian(shoplogo)"></image>
				<image class="aimg" src="/static/image/me/change.png" v-if="state==1" @tap="touxiang"></image>
			</view>
			<view class="content-lang" v-for="(item,index) in list" :key="index" v-if="state==item.state&&index!==2 ">
				
				<view class="font-duble" v-if=" index !== 4">{{item.title}}</view>
				<view class="color-font neirong_s"v-if=" index !== 4">{{item.content}}</view>
			</view>
			<view class="content-lang_ jianjie" v-if="state==0">
				<view class="font-duble">店铺简介</view>
			</view>
			<view class="content-lang jianjie" v-if="state==0">
				<view class="color-font neirong">{{jianjie}}</view>
			</view>
			
		</view>
		<requestLoading></requestLoading>
	</view>
</template>
<script>
	import shangchuan from '@/configure/shangchuan.js'; 
	export default {
		data() {
			return {
				tishi: 1 ,//展示加载动画
				list: [{
					title: "姓名",
					content: "--",
					state:1
				}, {
					title: "账号",
					content: "--",
					state:1
				}, {
					title: "性别",
					content: "--",
					state:1
				}, {
					title: "联系方式",
					content: "--",
					state:1
				}, {
					title: "住址",
					content: "--",
					state:1
				}, 
				{
					title: "入驻时间",
					content: "--",
					state:1
				},
				{
					title: "账号类型",
					content: "--",
					state:1
				}, {
					title: "店名",
					content: "--",
					state:0
				}, {
					title: "账号",
					content: "--",
					state:0
				},{
					title: "当前负责人",
					content: "--",
					state:0
				}, {
					title: "服务种类",
					content: "--",
					state:0
				}, {
					title: "入驻时间",
					content: "--",
					state:0
				}, {
					title: "店铺地址",
					content: "--",
					state:0
				}],
				
				avatar:'', //头像
				title:'',
				
				state:'',
				shoplogo:'',
				jianjie:''
					
				
			}
		},
		onLoad(option) {
			// 0店铺  1个人
			if(option.state==0){
				this.title='店铺信息'
			}else{
				this.title='个人资料';
			}
			this.state=option.state;
			this.gerenziliao(option.state,"option.state");
		},
		methods: {
			gerenziliao() {
				var that = this;
				this.configure.ajax({
					url: 'wode/selfxiangqing',
					tishi: that.tishi,
					data: {
						type : that.state
					},
					method: 'POST',
					success: function(res) {
						console.log("成功")
						
						// that.avatar = res.data.user.avatar;
						uni.setStorageSync('userinfo',res.data);
						
						if(that.state == 1){
							that.avatar = res.data.user.avatar;
							console.log(res.data.user.avatar,"res.data.user.avatar")
							that.list[0].content = res.data.user.nick_name;
							that.list[1].content = res.data.user.user_name;
							that.list[2].content = res.data.user.sex;
							that.list[3].content = res.data.user.phonenumber;
							that.list[4].content = res.data.user.s_address;
							that.list[5].content= res.data.user.newtime;
							that.list[6].content = res.data.user.remark;
						}else if(that.state == 0){
							that.shoplogo = res.data.shop.shoplogo;
							that.list[7].content = res.data.shop.shopname;
							that.list[8].content = res.data.shop.shopidnum	;
							that.list[9].content = res.data.shop.nick_name;
							that.list[10].content= res.data.shop.shop_type;
							that.list[11].content = res.data.shop.time;
							that.list[12].content= res.data.shop.shopaddress;
							that.jianjie = res.data.shop.shopbrief;
						}
						
					
						
					}
				})
			},
			//  时间戳转化
			touxiang() {
				var that=this;
				shangchuan.ajax({
					success: function(res) {
						that.xiugai(res)
					}
				})
			},
			xiugai(avatar){
				console.log(avatar)
				var that = this;
				this.configure.ajax({
					url: 'upload/changeimg',
					tishi: that.tishi,
					data: {
						url:avatar,
					},
					method: 'GET',
					success: function(res) {
						console.log('上传成功')
						that.avatar=avatar;
					}
				})
			}
		}
	}
</script>

<style scoped lang="scss">
	.neirong_s{
		width: calc(100% - 180rpx);
	}
	.middle-content {
		margin: auto;
		margin-top: 72rpx;
		margin-bottom: 50rpx;
		width: 230rpx;
		height: 230rpx;
		position: relative;
		image {
			width: 200rpx;
			height: 200rpx;
			border-radius: 50%;
			margin-left: 20rpx;
		}

		.aimg {
			width: 120rpx;
			height: 120rpx;
			position: absolute;
			right: 0;
			bottom: 0;
		}
	}

	.content-lang {
		display: flex;
		margin: auto;
		width: calc(100% - 140rpx);
		// height: 90rpx;
		border-bottom: 2rpx solid $qianhui_eee;
		line-height: 90rpx;
		font-size: 30rpx;

		.font-duble {
			font-weight: bold;
			text-align: justify;
			text-align-last: justify;
			width: 150rpx;
			margin-right: 30rpx;

		}

		.color-font {
			color: $qianhui_ziti;
		}
	}
	.content-lang_{
		display: flex;
		margin: auto;
		width: calc(100% - 140rpx);
		// height: 90rpx;
		// border-bottom: 2rpx solid $qianhui_eee;
		line-height: 90rpx;
		font-size: 30rpx;
		
		.font-duble {
			font-weight: bold;
			text-align: justify;
			text-align-last: justify;
			width: 150rpx;
			margin-right: 30rpx;
		
		}
		
		.color-font {
			color: $qianhui_ziti;
		}
	}
	.jianjie{
		display: flex;
		flex-wrap: wrap;
		margin-bottom: 40rpx;
	}
	.neirong{
		 line-height: 26px;
		 text-indent: 60rpx;
	}
	.content-lang:last-child {
		border-bottom: 0rpx;
	}
</style>
